/**
 * 
 */
package com.cipe.cmrs.util;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author Incepio
 *
 */

public class SpringContextProvider {

	protected static ApplicationContext applicationContext;

	// Make is singleton
	private SpringContextProvider() {		
	}

    public static void setContext(ApplicationContext ctx) {
        applicationContext = ctx;
    }
    
    /**
     * 
     * @return application context with all the context files
     */
    public static synchronized ApplicationContext getContext() {
        if (applicationContext != null) {
            return applicationContext;
        } else {            
            applicationContext = new ClassPathXmlApplicationContext("classpath*:applicationContext.xml");
            return applicationContext;
        }
    }

}